<?php
/*------------------------------------------------------------------------
# com_vportfolio - Vportfolio component
# ------------------------------------------------------------------------
# author    Vsmart Extensions
# copyright Copyright (C) 2010 www.vsmart-extensions.com. All Rights Reserved.
# @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: http://www.vsmart-extensions.com
# Technical Support:  Forum - http://www.vsmart-extensions.com
-------------------------------------------------------------------------*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.controller' );

/**
 * Note: this view is intended only to be opened in a popup
 * @package Joomla
 * @subpackage Vportfolio
 */
class vportfolioConfigController extends JController
{

	/**
	 * Custom Constructor
	 */
	//DEVNOTE: register task - Register (map) a task to a method in the class
	//function registerTask( $task, $method )
	function __construct( $default = array())
	{
		parent::__construct( $default );
	}
	function execute($task){
		switch($task){
			case  "cancel":
				$this->cancel();
				break;
			case "save":
			case "apply":
				$this->save($task);
				break;
			default:
				$this->display();
				break;
		}
	}

	/**
	 * Cancel operation
	 */
	function cancel()
	{
		$this->setRedirect( 'index.php?option=com_vportfolio&controller=vportfolio' );
	}
	
	function display() 
  	{
  	   
	   $model = &JModel::getInstance( 'vportfolioConfigComponentModel' );
	   $config = $model->getConfig();
		
	   $view = new vportfolioConfigComponentView( );
	   $view->display($config);
  	}
   function save($task){
	$model = &JModel::getInstance( 'vportfolioConfigComponentModel' );
	
	$model->saveConfig();
	
	$msg = JText::sprintf( 'Successfully Saved Config');
	
	if($task == "save")
		$this->setRedirect( 'index.php?option=com_vportfolio&controller=vportfolio', $msg );
	else
		//$this->display();
		$this->setRedirect( 'index.php?option=com_vportfolio&controller=config', $msg );
  }
}
?>
